import {PLUS, SUB} from '../type'

// 同步执行加法
export const plusAction = (data) => ({type: PLUS, data})

// 同步执行减法
export const subAction = (data) => ({type: SUB, data})

// 异步执行加法
export const plusAsyncAction = (data) => {
    return (dispatch) => {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                dispatch(plusAction(data))
                resolve(data)
            }, 1500)
        })
    }
}

// 异步执行减法
export const subAsyncAction = (data) => {
    return (dispatch) => {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                dispatch(subAction(data))
                resolve(data)
            }, 1500)
        })
    }
}
